package com.yonyou.crm.bpub.topbar.service;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yonyou.crm.base.brand.entity.BrandVO;
import com.yonyou.crm.base.brand.service.BrandsBizServiceImpl;
import com.yonyou.crm.bpub.topbar.entity.*;
import com.yonyou.crm.common.filter.entity.AppFilterTypeConstant;
import com.yonyou.crm.common.search.entity.AppSearchPlanEnum;
import com.yonyou.crm.common.sort.entity.AppSortPlanEnum;

@Service
public class LeadTopbar extends BaseTopbar {

	@Autowired
	BrandsBizServiceImpl branchBizService;
	
	@Override
	public PlanVO getPresetOptions(){
		PlanVO presetOption = new PlanVO();
		presetOption.setTitle("预置选择");
		
		List<DataItemVO> data = new ArrayList<>();
		DataItemVO item;
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.ALL.getValue()), AppSearchPlanEnum.ALL.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.OWNER.getValue()), AppSearchPlanEnum.OWNER.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.REL.getValue()), AppSearchPlanEnum.REL.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.FOLLOW.getValue()), AppSearchPlanEnum.FOLLOW.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.CONVERSION.getValue()), AppSearchPlanEnum.CONVERSION.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.CLOSE.getValue()), AppSearchPlanEnum.CLOSE.getName());
		data.add(item);
		
		presetOption.setData(data);
		return presetOption;
	};
	
	@Override
	public String getSearchPlaceholder(){
		String searchText = "搜索线索名称";
		return searchText;
	}
	
	@Override
	public PlanVO getSortData(){
		PlanVO sortData = new PlanVO();
		sortData.setTitle("排序");
		
		List<DataItemVO> data = new ArrayList<>();
		DataItemVO item;
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.FOLLOWUPTIME.getValue()), AppSortPlanEnum.FOLLOWUPTIME.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.MODIFYTIME.getValue()), AppSortPlanEnum.MODIFYTIME.getName());
		data.add(item);

		sortData.setData(data);
		return sortData;
	};
	
	@Override
	public List<SelectDataVO> getSelectData(){
		List<SelectDataVO> selectData = new ArrayList<SelectDataVO>();
		
		SelectDataVO select;
		List<DataItemVO> data;
		DataItemVO item;
		
		select = new SelectDataVO();
		select.setKey("owner");
		select.setType(AppFilterTypeConstant.Refer);
		select.setTitle("负责人");
		select.setReferto("user");
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("province");
		select.setType(AppFilterTypeConstant.Refer);
		select.setTitle("省份");
		select.setReferto("province");
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("industry");
		select.setType(AppFilterTypeConstant.Refer);
		select.setTitle("行业");
		select.setReferto("industry");
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("followTime");
		select.setType(AppFilterTypeConstant.DateRanger);
		select.setTitle("最后跟进时间");
		data = new ArrayList<>();
		item = new DataItemVO("start","开始时间");
		data.add(item);
		item = new DataItemVO("end","结束时间");
		data.add(item);
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("levels");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("线索等级");
		data = new ArrayList<>();
		data = getEnumList("lead_level");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("sources");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("线索来源");
		data = new ArrayList<>();
		data = getEnumList("lead_source");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("states");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("线索状态");
		data = new ArrayList<>();
		data = getEnumList("lead_state");
		select.setData(data);
		selectData.add(select);
		
		return selectData;
	}

}
